package main.gui.action;

import java.awt.event.ActionEvent;
import java.io.File;
import java.io.FileNotFoundException;

import javax.swing.AbstractAction;

import main.FileManager;
import main.Worker;
import main.gui.App;

@SuppressWarnings("serial")
public class LoadAction extends AbstractAction {
  private final App app;

  public LoadAction(App app) {
    this.app = app;
  }

  @Override
  public void actionPerformed(ActionEvent e) {
    try {
      File file = new FileManager().askSourceFile();
      if (file == null) {
        return;
      }
      app.setCurrentData(new Worker(file).readData());
    }
    catch (FileNotFoundException e1) {
    }
  }
}